package thread;

public class ThreadDemo9_3 {

	public static void main(String[] args) {
		
		Ticket t1 = new Ticket("窗口1");
		Ticket t2 = new Ticket("窗口2");
		Ticket t3 = new Ticket("窗口3");
		t1.start();
		t2.start();
		t3.start();
	}

}

class Ticket extends Thread {
	private int ticket = 50;
	
	public Ticket(String name){
		super( name );
	}
	
	@Override
	public void run() {
		while(true){
			if( this.ticket > 0 ){
				System.out.println(Thread.currentThread().getName()+ "卖掉一张票,还有余票:" + --ticket);
			} else {
				break;
			}
		}
	}
	
}
